package pl.edu.agh.ssm.monitor.visualization;

import java.util.HashMap;

import pl.edu.agh.ssm.monitor.data.SessionConnection;
import pl.edu.agh.ssm.monitor.data.SessionNode;
import prefuse.Display;
import prefuse.Visualization;
import prefuse.controls.NeighborHighlightControl;
import prefuse.controls.PanControl;
import prefuse.controls.WheelZoomControl;
import prefuse.controls.ZoomControl;
import prefuse.controls.ZoomToFitControl;

/**
 * 
 * @author Monika Nawrot
 * 
 * Monitor display with one-to-one mapping to single
 * graph presenting state of one session
 */

public class MonitorDisplay extends Display {

	private static final long serialVersionUID = 1L;

	private NetGraph graph = null;
		
	public MonitorDisplay() {
		super(new Visualization());
			
		/* init visualization with data graph */
		graph = new NetGraph(m_vis);

		HashMap<String, SessionNode> nodesMap = new HashMap<String, SessionNode>();
		HashMap<String, SessionConnection> connectionsMap = new HashMap<String, SessionConnection>();
		graph.setConnectionsMap(connectionsMap);
		graph.setNodesMap(nodesMap);
		
		setHighQuality(true);
		
		/* add actions */
        addControlListener(new GraphFocusControl(nodesMap, connectionsMap));
        addControlListener(new PanControl());
        addControlListener(new ZoomControl());
        addControlListener(new WheelZoomControl());
        addControlListener(new ZoomToFitControl());
        addControlListener(new NeighborHighlightControl());       
        addControlListener(new AggregateDragControl());

		/* run visualization */
		m_vis.run("layout");
	}

	public NetGraph getGraph() {
		return graph;
	}

	

}

